<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/21
 * Time: 16:41
 */

namespace app\mobile\controller;
use cmf\controller\HomeBaseController;
use think\Db;

class IndexController extends HomeBaseController
{

    public function index()
    {
               //查询律师列表
        $team_list = $this->getList('top desc',4);

        $this->assign('team_list',$team_list);
        return $this->fetch(':index');
    }


    //案例
    public function anli()
    {

        return $this->fetch(':anli');

    }

    //案例详情
    public function case_details()
    {
        $id = request()->param('id');

        $details = Db::name('portal_post' )->alias('p')->join('team t','p.team_id = t.id','left')->where('p.id',$id)->field('p.*,t.user_name,t.position,t.portrait')->find();

        $this->assign('detail',$details);
        return $this->fetch(':detail');
    }

    //计算器
    public function computer()
    {

        return $this->fetch(':computer');
    }

    //律师团队
    public function team()
    {
        $team_list = $this->getList('top desc',8);

        $this->assign('team_list',$team_list);
        return $this->fetch(':team');
    }

    //律师个人主页
    public function lawyer()
    {
        $id = request()->param('id');
        $user_info = Db::name('team')->where('id',$id)->find();

        $this->assign('user_info',$user_info);
        return $this->fetch(':lawyer');
    }



    //关于我们
    public function mine()
    {

        return $this->fetch(':mine');
    }

    /**
     * 公共获取律师列表
     * @param string $order
     * @param int $limit
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getList($order='',$limit=0)
    {

        //查询律师列表
        $team_list = Db::name('team')->field('id,user_name,position,portrait,describe,describe_two,describe_three')->order($order)->limit($limit)->select();

        return $team_list;
    }


    /**
     * 首页律师接口
     */
    public function team_list()
    {
        $page = request()->param('number');

        $list = Db::name('team')->where('status',1)->field('id,user_name,position,portrait,describe,describe_two,describe_three')->paginate($page);

        return json($list);
    }




}